'use strict';

function compute_chain_median(collection) {
  
let arr = collection.split(/->/);
let num_arr=arr.map((x)=>{
  return parseInt(x);
})

function sortArr(a,b){
  return a-b;
}
num_arr.sort(sortArr);

if(num_arr.length%2 == 0){
  return ( num_arr[num_arr.length/2-1] + num_arr[num_arr.length/2] ) / 2
}else{
  return num_arr[parseInt(num_arr.length/2)];
}

}

module.exports = compute_chain_median;
